import 'package:json2dart_safe/json2dart.dart';

import 'activity_user_model.dart';

class ActivityDetailModel {
  String? id;
  int? activityId;
  String? activityName;
  String? coverImg;
  String? activityDate;
  String? location;
  String? locationDetail;
  String? organizerId;
  String? organizerName;
  String? organizerProfilePicture;
  int? participantLimit;
  int? currentParticipants;
  int? status;
  String? description;
  List<String>? detailImages;
  List<String>? tags;
  List<ActivityUserModel>? participants;
  bool? isPaidEvent;
  double? price;
  String? url;
  String? createdAt;
  String? updatedAt;
  bool? isReview;
  bool? alreadyJoin;
  ActivityDetailModel(
      {this.id,
      this.activityId,
      this.activityName,
      this.coverImg,
      this.activityDate,
      this.location,
      this.locationDetail,
      this.organizerId,
      this.organizerName,
      this.organizerProfilePicture,
      this.participantLimit,
      this.currentParticipants,
      this.status,
      this.description,
      this.detailImages,
      this.tags,
      this.participants,
      this.isPaidEvent,
      this.price,
      this.url,
      this.createdAt,
      this.updatedAt,
      this.isReview,
      this.alreadyJoin});

  Map<String, dynamic> toJson() {
    return Map<String, dynamic>()
      ..put('id', this.id)
      ..put('activityId', this.activityId)
      ..put('activityName', this.activityName)
      ..put('coverImg', this.coverImg)
      ..put('activityDate', this.activityDate)
      ..put('location', this.location)
      ..put('locationDetail', this.locationDetail)
      ..put('organizerId', this.organizerId)
      ..put('organizerName', this.organizerName)
      ..put('organizerProfilePicture', this.organizerProfilePicture)
      ..put('participantLimit', this.participantLimit)
      ..put('currentParticipants', this.currentParticipants)
      ..put('status', this.status)
      ..put('description', this.description)
      ..put('detailImages', this.detailImages)
      ..put('tags', this.tags)
      ..put('participants', this.participants?.map((v) => v.toJson()).toList())
      ..put('isPaidEvent', this.isPaidEvent)
      ..put('price', this.price)
      ..put('url', this.url)
      ..put('isReview', this.isReview)
      ..put('alreadyJoin', this.alreadyJoin)
      ..put('createdAt', this.createdAt)
      ..put('updatedAt', this.updatedAt);
  }

  ActivityDetailModel.fromJson(Map<String, dynamic> json) {
    this.id = json.asString('id');
    this.activityId = json.asInt('activityId');
    this.activityName = json.asString('activityName');
    this.coverImg = json.asString('coverImg');
    this.activityDate = json.asString('activityDate');
    this.location = json.asString('location');
    this.locationDetail = json.asString('locationDetail');
    this.organizerId = json.asString('organizerId');
    this.organizerName = json.asString('organizerName');
    this.organizerProfilePicture = json.asString('organizerProfilePicture');
    this.participantLimit = json.asInt('participantLimit');
    this.currentParticipants = json.asInt('currentParticipants');
    this.status = json.asInt('status');
    this.description = json.asString('description');
    this.detailImages = json.asList<String>('detailImages', null);
    this.tags = json.asList<String>('tags', null);
    this.participants = json.asList<ActivityUserModel>(
        'participants', (v) => ActivityUserModel.fromJson(v));
    this.isPaidEvent = json.asBool('isPaidEvent');
    this.isReview = json.asBool('isReview');
    this.alreadyJoin = json.asBool('alreadyJoin');
    this.price = json.asDouble('price');
    this.url = json.asString('url');
    this.createdAt = json.asString('createdAt');
    this.updatedAt = json.asString('updatedAt');
  }

  static ActivityDetailModel toBean(Map<String, dynamic> json) =>
      ActivityDetailModel.fromJson(json);
}
